Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

joystick: fix race condition in joystick control #34187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deanlee
Copy link
Contributor

@deanlee deanlee commented Dec 9, 2024

This PR fixes a race condition in the joystick control by using threading.Lock to safely synchronize access to shared joystick data between threads. This prevents data conflicts and ensures reliable operation during concurrent execution.

@github-actions github-actions bot added the tools label Dec 9, 2024
@deanlee deanlee marked this pull request as ready for review December 9, 2024 08:33
@adeebshihadeh
Copy link
Contributor

Does this actually fix anything?

@deanlee
Copy link
Contributor Author

deanlee commented Dec 19, 2024

This resolves the race condition. While Python's GIL prevents crashes from concurrent accesses, like those seen in C/C++, it doesn't eliminate the risk of race conditions causing inconsistent behavior.

The lock is important in this case. Without it, joystick data can become inconsistent, leading to issues like sudden jumps or incorrect inputs. The lock addresses these problems, ensuring smooth and reliable joystick control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants